﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using NGroup.VTL.WebCore;

namespace NGroup.VTL.Models
{
    public class OrderModel
    {
        public int? ID { get; set; }

        [Required]
        public string CustomerName { get; set; }

        [Required]
        public string CustomerPhone { get; set; }

        [Required]
        public string ShippingAddress { get; set; }

        public DateTime OrderDate { get; set; }

        public int? ProductSupTypeID { get; set; }

        public int? ProductTypeID { get; set; }

        public int? ProductID { get; set; }

        [Required]
        public int Amount { get; set; }

        public decimal TotalPrice { get; set; }

        public bool IsActive { get; set; }

        public string UniqueString { get; set; }

        public string SupTypeIDString
        {
            get
            {
                var supItem = AppContentTypes.All.Find(e => !e.SupTypeID.HasValue && e.TypeID.Value == ProductSupTypeID);
                return supItem != null ? supItem.UniqueString : null;
            }
        }
       
        public string TypeIDString
        {
            get
            {
                var childItem = AppContentTypes.All.Find(e => e.SupTypeID.HasValue && e.TypeID.Value == ProductTypeID);
                return childItem != null ? childItem.UniqueString : null;
            }
        }
    }
}